﻿<%@ Page Language="C#" AutoEventWireup="true" Codebehind="valuablespreview.aspx.cs"
    Inherits="LabMS.Web.Equipment.Valuables.valuablespreview" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>贵重仪器一览</title>
    <link type="text/css" rel="stylesheet" href="../../style/screen.css" />
    <!--[if lte IE 6]>
    <link type="text/css" rel="stylesheet" href="../../style/ie6.css" />
    <![endif]-->
    <!--[if lte IE 7]>
    <link type="text/css" rel="stylesheet" href="../../style/ie7.css" />
    <![endif]-->

    <script type="text/javascript" src="../../js/Common.js"></script>

    <script type="text/javascript" src="../../js/Calendar5.js"></script>

    <script type="text/javascript">
    var c = new Calendar("c");
    document.write(c);
    </script>

</head>
<body class="mainBody">
    <form id="form1" runat="server">
        <div class="main">
            <div id="pageInfo" class="clearfix">
                <div class="title">
                    <label>
                        贵重仪器一览</label>
                </div>
            </div>
        </div>
        <div class="main">
            <p>
                <%--<asp:CheckBox ID="checkall" runat="server" Text="全选" />--%>
                <input id="Button1" class="button" type="button" value="导出到Excel" />
                <% if (UserType == "mana")
                    {%>
                <asp:Button ID="lbDelete" CssClass="button" runat="server" Text="删除" OnClick="Button2_Click" />
                <%} %>
            </p>
            <p>
                <asp:DropDownList ID="ddlCClass" runat="server" Height="20px" Width="100px">
                    <asp:ListItem Text="名称" Value="Name"></asp:ListItem>
                    <asp:ListItem Value="Numbers">编号</asp:ListItem>
                </asp:DropDownList>
                关键字<asp:TextBox ID="tbKeyWords" runat="server"></asp:TextBox>
                <label>
                    入库时间</label>
                <asp:TextBox ID="tbCreateDateMin" runat="server"></asp:TextBox>
                --
                <asp:TextBox ID="tbCreateDateMax" runat="server"></asp:TextBox>
                <label>
                    用途</label>
                <asp:TextBox ID="tbPurpose" runat="server"></asp:TextBox>
                <asp:Button ID="btSearch" CssClass="button" runat="server" Text="搜索" OnClick="btSearch_Click" />
                <asp:Button ID="btUpdate" CssClass="button" runat="server" Text="刷新" OnClick="btUpdate_Click" />
            </p>
            <asp:GridView ID="GridViewValuables" runat="server" AutoGenerateColumns="False" AllowPaging="True"
                PageSize="15" Width="100%" OnPageIndexChanging="GridViewValuables_PageIndexChanging"
                OnRowDataBound="GridViewValuables_RowDataBound" DataKeyNames="ID" CssClass="infoTable"
                OnRowCreated="GridViewValuables_RowCreated">
                <Columns>
                    <asp:TemplateField>
                        <HeaderTemplate>
                            <asp:CheckBox ID="CBAll" runat="server" />
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox runat="server" ID="checkdel" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="Numbers" HeaderText="贵重仪器编号" SortExpression="Numbers" />
                    <asp:BoundField DataField="Name" HeaderText="贵重仪器名称" />
                    <asp:BoundField DataField="PurchaseDate" HeaderText="购置日期" DataFormatString="{0:yyyy/MM/dd}" />
                    <asp:BoundField DataField="Quantity" HeaderText="数量" SortExpression="Quantity" />
                    <asp:BoundField DataField="UnitPrice" HeaderText="单价" SortExpression="UnitPrice" />
                    <asp:BoundField DataField="Arrow" HeaderText="使用方向" />
                    <asp:BoundField DataField="Source" HeaderText="来源" />
                    <asp:BoundField DataField="PresentSituation" HeaderText="状态" />
                    <asp:BoundField DataField="LabName" HeaderText="存放位置" />
                </Columns>
                <HeaderStyle CssClass="header" />
                <RowStyle HorizontalAlign="Center" />
                <EmptyDataTemplate>
                    <a style="color: Red">无数据</a>
                </EmptyDataTemplate>
            </asp:GridView>
        </div>
        <asp:Label ID="Err" runat="server"></asp:Label>
    </form>

    <script type="text/javascript" src="../../js/jQuery/jquery-1.3.1.js"></script>

    <script type="text/javascript" src="../../js/site.js"></script>

    <script type="text/javascript">

        $(function(){
            /* 修改样式 */
            $("#GridViewValuables > tbody > tr:even").not(":first").addClass("even");
            $("#GridViewValuables > tbody > tr").not(":first")
                .hover(
                    function(){
                        $(this).addClass("hover");
                    },
                    function(){
                        $(this).removeClass("hover");
                });

            /* 全选 */
            $("#GridViewValuables > tbody > tr:first :checkbox").click(function(){
                if ($(this).attr("checked")){
                    $("#GridViewValuables :checkbox").attr("checked", "checked");
                    cbChanged();
                } else{
                    $("#GridViewValuables :checkbox").attr("checked", "");
                    cbChanged();
                }
            });

            /* Checkbox事件 */
            $("#GridViewValuables :checkbox").not(":first").click(cbChanged);

            cbChanged();
        });

        /* 检测Checkbox的选择状态，更改button的disabled属性 */
        function cbChanged(){
            var hasChecked = false;
            var allChecked = true;
            $("#GridViewValuables :checkbox").not(":first").each(function(index, domEle){
                var curChecked = $(domEle).attr("checked");
                if (!hasChecked && curChecked){
                    hasChecked = true;
                }

                allChecked &= curChecked;
            });

            if (hasChecked){
                $("#lbDelete").attr("disabled", "");
            } else {
                $("#lbDelete").attr("disabled", "disabled");
            }

            if (allChecked){
                $("#GridViewValuables :checkbox").filter(":first").attr("checked", "checked");
            } else {
                $("#GridViewValuables :checkbox").filter(":first").attr("checked", "");
            }
        }
    </script>

</body>
</html>
